<?php

function display($zarray,$field,$delim,$caller,$point){

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Order contence</title>
<meta name="robots" content="noindex,nofollow" />
<link rel="stylesheet" href="theme/standardtheme/adminstyle.css" type="text/css" media="screen" />
</head>
<body>
<?php

	echo "<br />";
	
	//if (isset($_SESSION['zarray'])){echo "Is set ";}
	unset($sarray);
	$cnt=0;
	foreach($zarray as $line){
		$tmpline=explode($delim,$line);
		echo "<b>" .$tmpline[$field] ."</b><br />";
		$sarray[$cnt]=$tmpline[$field];
		//echo strlen($sarray[$cnt]) ."  ";
		$cnt++;
	}
	?>

<br />
<form action="<?php echo $caller; ?>" method="post" >
<select name="doorder" >
<?php if ($point<0){ echo '<option selected="">Make Selection</option>';}

	$cnt=0;
	foreach($sarray as $val){
		if ($point==$cnt){ 
			echo '<option selected="' .$cnt .'" value="' .$cnt .'" size="32" >' .$val .'</option>';
		}else{
			echo '<option value="' .$cnt .'" size="32" >' .$val .'</option>';
		}
//		echo '<option id="dorder" name="dorder" value="' .$cnt .'" >' .$val .'</option>\n';
		$cnt++;
	}
	?></select><br /><br />
<input type="submit" value="Move Up" title="submit" name="up" />
<input type="submit" value="Move Down" title="submit" name="down" />
<input type="submit" value="Save the order" title="submit" name="Save" />
</form>

</body>
</html>
	<?php
}

function moveup($zarray,$id,$field,$delim,$caller){

	$point=$id;
	if ($id > 0 && $id < count($zarray)){
		$tmp=$zarray[$id];
		$point=$id-1;
		$zarray[$id]=$zarray[$point];
		$zarray[$point]=$tmp;
	}	
	display($zarray,$field,$delim,$caller,$point);
	return $zarray;
}

function movedown($zarray,$id,$field,$delim,$caller){

	$point=$id;
	if ($id > -1 && $id < count($zarray)-1){
		$tmp=$zarray[$id];
		$point=$id+1;
		$zarray[$id]=$zarray[$point];
		$zarray[$point]=$tmp;
	}	
	display($zarray,$field,$delim,$caller,$point);
	return $zarray;
}

?>
